package sw6.admin.gui.logic;

import java.io.Serializable;
import java.util.ArrayList;

import sw6.admin.internal.Definitions;

import android.app.Dialog;

/**
 * This class is a data container. It contains information about a given setting.
 * @author sw6b
 *
 */
public class Setting implements Serializable {
	
	private static final long serialVersionUID = 1366497887913548714L;
	String mDataType;
	String mRealName;
	String mVarName;
	String mDescription;
	String mClassPath = "";
	double mDoubleMin;
	double mDoubleMax;
	int mIntMin;
	int mIntMax;
	boolean mMinSet = false;
	boolean mMaxSet = false;
	String mActivity;
	String mPc;
	String mTypeName;
	
	public String getTypeName() {
		return mTypeName;
	}

	public void setTypeName(String mTypeName) {
		this.mTypeName = mTypeName;
	}

	public String getActivity() {
		return mActivity;
	}

	public void setActivity(String mActivity) {
		this.mActivity = mActivity;
	}

	public String getPc() {
		return mPc;
	}

	public void setPc(String mPc) {
		this.mPc = mPc;
	}

	ArrayList<SettingEnumElement> mEnumElements;
	
	public ArrayList<SettingEnumElement> getEnumElements() {
		return mEnumElements;
	}

	public void setEnumElements(ArrayList<SettingEnumElement> enumElements) {
		this.mEnumElements = enumElements;
	}

	Dialog mDialog;
	
	public String getClassPath() {
		return mClassPath;
	}
	
	public String getDataType() {
		return mDataType;
	}

	public void setDataType(String mDataType) {
		this.mDataType = mDataType;
	}

	public String getRealName() {
		return mRealName;
	}

	public void setRealName(String mRealName) {
		this.mRealName = mRealName;
	}

	public String getVarName() {
		return mVarName;
	}
	
	public double getDoubleMin() {
		return mDoubleMin;
	}
	
	public double getDoubleMax() {
		return mDoubleMax;
	}
	
	public int getIntMin() {
		return mIntMin;
	}
	
	public int getIntMax() {
		return mIntMax;
	}

	public void setVarName(String mVarName) {
		this.mVarName = mVarName;
	}

	public String getDescription() {
		return mDescription;
	}

	public void setDescription(String mDescription) {
		this.mDescription = mDescription;
	}
	
	public void setDialog(Dialog dialog) {
		mDialog = dialog;
	}
	
	public Dialog getDialog() {
		return mDialog;
	}
	
	public boolean isBoundBellowIntMin(int value) {
		return (value < mIntMin);
	}
	
	public boolean isBoundAboveIntMin(int value) {
		return (value > mIntMin);
	}
	
	public boolean isBoundAboveDoubleMin(double value) {
		return (value > mDoubleMin);
	}
	
	public boolean isBoundBellowDoubleMin(double value) {
		return (value < mDoubleMin);
	}
	
	public boolean isMinSet() {
		return mMinSet;
	}

	public boolean isMaxSet() {
		return mMaxSet;
	}
	
	public boolean isSmallerIntMin(int value) {
		return (value < mIntMin);
	}
	
	public boolean isLargerIntMin(int value) {
		return (value > mIntMax);
	}
	
	public boolean isSmallerDoubleMin(double value) {
		return (value < mDoubleMin);
	}
	
	public boolean isLargerDoubleMin(double value) {
		return (value > mDoubleMax);
	}
	
	public boolean isInteger() {
		return (mDataType.equals(Definitions.XML_SETTING_TYPE_INT));
	}
	
	public boolean isDouble() {
		return (mDataType.equals(Definitions.XML_SETTING_TYPE_DOUBLE));
	}
	
	public boolean isString() {
		return (mDataType.equals(Definitions.XML_SETTING_TYPE_STRING));
	}
	
	public boolean isBoolean() {
		return (mDataType.equals(Definitions.XML_SETTING_TYPE_BOOLEAN));
	}
	
	public boolean isEnum() {
		return (mDataType.equals(Definitions.XML_SETTING_TYPE_ENUM));
	}

	public Setting(String dataType, String realName, String varName, String description, String classPath, double doubleMin, double doubleMax, int intMin, int intMax, String activity, String pc, String typeName) {
		mDataType = dataType;
		mRealName = realName;
		mVarName = varName;
		mDescription = description;
		mClassPath = classPath;
		mDoubleMin = doubleMin;
		mDoubleMax = doubleMax;
		mIntMin = intMin;
		mIntMax = intMax;
		mActivity = activity;
		mPc = pc;
		mTypeName = typeName;
		
		if (doubleMin != -Double.MAX_VALUE || intMin != Integer.MIN_VALUE) {
			mMinSet = true;
		}
		if (doubleMax != Double.MAX_VALUE || intMax != Integer.MAX_VALUE) {
			mMaxSet = true;
		}
	}
}
